<?php
namespace App\Http\Requests\Home;

use App\Http\Requests\Request;

class UpdatePasswordRequest extends Request
{

    /**
     * 应用于请求的验证规则。
     *
     * @return array
     */
    public function rules()
    {
        $user = $this->user();

        return [
            'password_current' => 'required|string|between:8,16',
            'password' => ['required', 'string', 'between:8,16', 'letters', 'case_diff', 'numbers', 'symbols', 'confirmed',
                function ($attribute, $password, $fail) use ($user) {
                    if ($user->email == $password) {
                        $fail(trans('validation.pwd_email_diff'));
                    }
                }
            ],
            'password_confirmation' => ['required', 'string', 'between:8,16', 'letters', 'case_diff', 'numbers', 'symbols']
        ];
    }

    /**
     * 自定义验证规则的错误消息。
     *
     * @return array
     */
    public function messages()
    {
        return [];
    }

    /**
     * 自定义字段名称。
     *
     * @return array
     */
    public function attributes()
    {
        return [];
    }
}
